import store from '@/store'
import userController from '@/api/userController/index'
const user = {
  getUserInfo:function(){
    var userInfo =  store.state.userInfo.userInfo;
    if(!userInfo){ //如果无userInfo
      userController.getLoginUserInfo().then(response=>{//获取用户信息
        store.dispatch('setUserInfo',response.data).then(()=>{
          return response.data
        })
      }).catch(()=>{ //网络请求错误
        let res = {
          isLogin:'1',
          success:false
        }
         return res
      })
    }
    return userInfo
  }
}
export default user
